****************************************************************************
*This file builds vars on population by education level from the Census/ACS*
****************************************************************************

use "$list/czones_list.dta", clear

merge 1:1 czone using "$clean_data_lmarket/czone1990_schooling_employment.dta", assert(3) nogenerate
merge 1:1 czone using "$clean_data_lmarket/czone2008_schooling_employment.dta", assert(3) nogenerate

foreach var of varlist ipums_* {
quiet replace `var' = 0 if mi(`var')
}

*Education level
foreach educ in b a l {

gen d_`educ' = 100*((ipums_pop_`educ'_2008/ipums_pop_2008)-(ipums_pop_`educ'_1990/ipums_pop_1990))

gen share_`educ'_1990 = 100*ipums_pop_`educ'_1990/ipums_pop_1990


foreach age in a19_34 a35_64 {

gen d_`educ'_`age' = 100*((ipums_pop_`educ'_`age'_2008/ipums_pop_`age'_2008)-(ipums_pop_`educ'_`age'_1990/ipums_pop_`age'_1990))

gen share_`educ'_`age'_1990 = 100*ipums_pop_`educ'_`age'_1990/ipums_pop_`age'_1990

}
}

*Keep variables on interest
keep czone share_* d_*

save "$final_data_outcomes/czone_CollegeEducatedLongDifferences.dta", replace






